﻿<%@ Page Title="Users" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="IFD2.Users" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <form id="form1" runat="server" role="form" class="form-inline" defaultbutton="lbtnQuery" autocomplete="off">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
    <div class="container-fluid body-content" style="width:100%;">

    <div class="row">
        <div class="col-sm-2 well well-sm">
            <h5><asp:Literal ID="litTitle" runat="server" meta:resourcekey="tipPageTitle"></asp:Literal></h5>
            <div class="form-group">
                <asp:Label ID="Label21" runat="server" Text="Office:" meta:resourcekey="Office"></asp:Label>
                <asp:Label ID="lblOffice" runat="server" Font-Bold="True" ></asp:Label><br />
                <asp:Label ID="Label31" runat="server" Text="Role:" meta:resourcekey="Role"></asp:Label>
                <asp:DropDownList ID="lstRoles" runat="server" cssclass="form-control input-sm" Width="100%" DataSourceID="sqlRoles" DataTextField="id" DataValueField="id"></asp:DropDownList>
            </div>
            <br class="hidden-xs"/><br class="hidden-xs"/>
            <asp:LinkButton ID="lbtnQuery" runat="server" CssClass="form-control input-sm btn-primary text-center" Width="100%" ToolTip="" meta:resourcekey="tipQuery" OnClick="lbtnQuery_Click"> <span class="glyphicon glyphicon-search" style="font-size:large;"></span></asp:LinkButton>
            <p></p><%--没有此行(或&nbsp;)，上面的按钮在手机模式(xs)下，只有上半部可以点击！--%>

            <asp:SqlDataSource ID="sqlRoles" runat="server" ConnectionString="<%$ ConnectionStrings:IFD_DB %>"
                SelectCommand="bll_office_get_roles" SelectCommandType="StoredProcedure" DataSourceMode="DataReader">
                <SelectParameters>
                    <asp:ControlParameter ControlID="lblOffice" Name="office" PropertyName="Text" Type="String" />
                    <asp:SessionParameter Name="user_office" SessionField="OFFICE" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
        </div>

        <div class="col-sm-10 well well-sm">
            <div class="panel">
                <div class="panel-heading btn-primary">
                    <h6 class="panel-title" id="section-2"><asp:Literal ID="Literal1" runat="server" meta:resourcekey="tipPageTitle"></asp:Literal></h6>
                </div>
                <div class="panel-body">
                    <div class="table-responsive">
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" style="min-width:800px;width:100%;" class="table-hover"
                            DataKeyNames="id" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <input name="KEY" type="radio" value='<%# Eval("id") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="id" HeaderText="User ID" ReadOnly="True" SortExpression="id"  meta:resourcekey="id1" />
                                <asp:BoundField DataField="name" HeaderText="Name" SortExpression="name"  meta:resourcekey="name1" />
                                <asp:BoundField DataField="owner_office" HeaderText="owner_office" SortExpression="owner_office"  meta:resourcekey="owner_office" />
                                <asp:BoundField DataField="identification" HeaderText="Identification" ReadOnly="True" SortExpression="identification"  meta:resourcekey="identification1" />
                                <asp:BoundField DataField="status" HeaderText="Status" SortExpression="status"  meta:resourcekey="status1" />
                                <asp:BoundField DataField="last_logon" HeaderText="Last Logon" SortExpression="last_logon"  meta:resourcekey="last_logon" />
                                <asp:BoundField DataField="done_user" HeaderText="Op." SortExpression="done_user"  meta:resourcekey="done_user" />
                                <asp:BoundField DataField="done_time" HeaderText="Op. Time" SortExpression="done_time"  meta:resourcekey="done_time" />
                            </Columns>
                            <RowStyle BackColor="#EFF3FB" />
                            <EditRowStyle BackColor="#2461BF" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>

                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IFD_DB %>"
                            SelectCommand="bll_role_get_users" SelectCommandType="StoredProcedure" DataSourceMode="DataReader">
                            <SelectParameters>
                                <asp:SessionParameter Name="airline" SessionField="AIRLINE" Type="String" />
                                <asp:ControlParameter ControlID="lblOffice" Name="office" PropertyName="Text" Type="String" />
                                <asp:ControlParameter ControlID="lstRoles" Name="role" PropertyName="SelectedValue" Type="String" />
                                <asp:SessionParameter Name="user_office" SessionField="OFFICE" Type="String" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </div>
                    <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click"  meta:resourcekey="Delete" CssClass="btn btn-sm btn-default" />

                    <div class="well well-sm">
                        <asp:Label ID="Label8" runat="server" Text="Status" meta:resourcekey="Status"></asp:Label>
                        <asp:DropDownList ID="lstStatus" runat="server">
                            <asp:ListItem Selected="True" Value="V" meta:resourcekey="Valid">V - Valid</asp:ListItem>
                            <asp:ListItem Value="L" meta:resourcekey="Locked">L - Locked</asp:ListItem>
                        </asp:DropDownList>
                        <asp:Button ID="btnSetStatus" runat="server" CssClass="btn btn-sm btn-default" OnClick="btnSetStatus_Click" Text="Set Status"  meta:resourcekey="SetStatus" />
                    </div>

                    <div class="well well-sm">
                        <asp:Label ID="Label7" runat="server" Text="New Password:" meta:resourcekey="NewPassword"></asp:Label>
                        <asp:TextBox ID="txtPwd2" runat="server" Width="108px" MaxLength="20" oninput="Shadow('MainContent_txtPwd2','MainContent_hidP2');"></asp:TextBox>
                        <asp:Button ID="btnSetPwd" runat="server" CssClass="btn btn-sm btn-default" Text="Reset Password" OnClick="btnSetPwd_Click"  meta:resourcekey="ResetPassword" />
                        <br />
                        <asp:Label ID="Label15" runat="server" Text="Password Restriction" meta:resourcekey="PasswordStrength" Font-Italic="true"></asp:Label>
                        <asp:HiddenField ID="hidP2" runat="server" />
                    </div>
                    <asp:Label ID="lblError" runat="server" CssClass="ifdMessage"></asp:Label>
                    <div class="well well-sm">
                        <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Create New User" meta:resourcekey="AddNewUser"></asp:Label><br />
                        <div class="form-group">
                        <asp:Label ID="Label4" runat="server" Text="ID:" meta:resourcekey="ID"></asp:Label>
                        <asp:TextBox ID="txtUid" runat="server" MaxLength="20"></asp:TextBox>
                        </div>
                        <div class="form-group">
                        <asp:Label ID="Label5" runat="server" Text="Name:" meta:resourcekey="Name"></asp:Label>
                        <asp:TextBox ID="txtName" runat="server" MaxLength="30"></asp:TextBox>
                        </div>
                        <div class="form-group">
                        <asp:Label ID="Label6" runat="server" Text="Password:" meta:resourcekey="Password"></asp:Label>
                        <asp:TextBox ID="txtPwd" runat="server" MaxLength="20" oninput="Shadow('MainContent_txtPwd','MainContent_hidP1');"></asp:TextBox>
                        </div>
                        <div class="form-group">
                        <asp:Label ID="Label12" runat="server" Text="Identification:" meta:resourcekey="Identification"></asp:Label>
                        <asp:TextBox ID="txtIdentification" runat="server" MaxLength="100"></asp:TextBox>
                        </div>
                        <asp:Button ID="btnAddNewUser" runat="server" CssClass="btn btn-sm btn-default" Text="Add" OnClick="btnAddNewUser_Click"  meta:resourcekey="Add" />
                        <asp:HiddenField ID="hidP1" runat="server" />
                    </div>

                    <div class="well well-sm">
                        <asp:Label ID="Label9" runat="server" Font-Bold="True" Text="Add Existing User" meta:resourcekey="AddExistingUser"></asp:Label>
                        <br />
                        <asp:Label ID="Label10" runat="server" meta:resourcekey="ID" Text="ID:"></asp:Label>
                        <asp:TextBox ID="txtUid2" runat="server" MaxLength="20"></asp:TextBox>
                        <asp:Button ID="btnFind" runat="server" Text="Find" onclick="btnFind_Click" meta:resourcekey="Find"  CssClass="btn btn-sm btn-default" /><br /> 
                        <div class="form-group">
                        <asp:Label ID="Label11" runat="server" meta:resourcekey="Name" Text="Name:" Visible="False"></asp:Label>
                        <asp:Label ID="lblUserName" runat="server" Font-Bold="True" Visible="False"></asp:Label>
                        </div>
                        <div class="form-group">
                        <asp:Label ID="Label14" runat="server" Text="Owner Office:" meta:resourcekey="OwnerOffice" Visible="False"></asp:Label>
                        <asp:Label ID="lblOwnerOffice" runat="server" Font-Bold="True" Visible="False"></asp:Label>
                        </div>
                        <div class="form-group">
                        <asp:Label ID="Label13" runat="server" meta:resourcekey="Identification" Text="Identification:" Visible="False"></asp:Label>
                        <asp:Label ID="lblIdentification" runat="server" Font-Bold="True" Visible="False"></asp:Label>
                        </div>
                        <asp:Button ID="btnAddExistingUser" runat="server" CssClass="btn btn-sm btn-default" Text="Add" meta:resourcekey="Add" onclick="btnAddExistingUser_Click" Visible="False" />
                    </div>

                    <asp:Label ID="lblHashed" runat="server" Text="" ForeColor="white"></asp:Label>
                </div>
            </div>
        </div>
    </div>

    </div>
    </ContentTemplate></asp:UpdatePanel>
    </form>

    <script src="JS/ScrollableGridPlugin.min.js"></script>
    <script src="JS/shadow.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var win_height = parseInt($(window).height());
            var tab_new_height = win_height - 50 - 50;//菜单占50， 表头占50
            if ($('#<%=GridView1.ClientID %>').height() > tab_new_height)
                $('#<%=GridView1.ClientID %>').Scrollable({ ScrollHeight: tab_new_height });
        });
    </script>

    <script type="text/JavaScript">
        <!-- Hide
        //function checkpwdlevel(pwd)
        //{
        //    pwd=pwd.trim();
        //    if(pwd.length<6)//low
        //    {
        //        alert("password is too short!");
        //        return false;
        //    }
        //    else
        //    {
        //        var p1= (pwd.search(/[a-zA-Z]/)!=-1) ? 1 : 0;//字母
        //        var p2= (pwd.search(/[0-9]/)!=-1) ? 1 : 0;//数字
        //        var p3= (pwd.search(/[^A-Za-z0-9]/)!=-1) ? 1 : 0;//非字母数字
        //        var pa=p1+p2+p3;
        //        if(pa==1)//low
        //        {
        //            alert("password is too weak!");
        //            return false;
        //        }
        //        else if(pa==2)//med
        //        {
        //            return confirm('Are you sure?')
        //        }
        //        else if(pa==3)//high
        //        {
        //            return confirm('Are you sure?')
        //        }
        //    }
        //}
        // -->
    </script>
</asp:Content>
